<%@ page import="com.qf.pojo.Student" %>
<%@ page import="com.qf.pojo.Address" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: glls
  Date: 2022/3/29
  Time: 15:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>el表达式快速入门---掌握</title>
</head>
<body>
    <%
        pageContext.setAttribute("name","zs");

        Student student = new Student();
        student.setName("ls");
        student.setAge(22);
        student.setAddress(new Address("河南","郑州"));

        request.setAttribute("student",student);
    %>

<%--    el表达式取普通数据--%>
    ${name}
    ${age2}
    <hr>
    <%--    el表达式取对象数据--%>

<%--    <%--%>
<%--       Student s = (Student) request.getAttribute("student");--%>

<%--       out.println(s.getName());--%>
<%--    %>--%>
    ${student.name}
    ${student.age}
    ${student.address.city}


    <hr>

    <%
        List<Student> students = new ArrayList<>();

        students.add(new Student("zs",18));
        students.add(new Student("ls",19));
        students.add(new Student("ww",20));


        request.setAttribute("students",students);


        HashMap<String, Student> map = new HashMap<>();
        map.put("a",new Student("zs",18));
        map.put("b",new Student("ls",18));
        map.put("c",new Student("ww",18));

        request.setAttribute("map",map);
    %>

    ${students[0].name}
    ${students[1].name}
    ${students[2].name}

<%--    实际开发 不能这样写   需要  配合  jstl 标签 遍历--%>
    <hr>

    ${map.a.name}
</body>
</html>
